package com.xuzm.netty.config;

import com.xuzm.netty.dto.ServerHandlerConsumer;
import com.xuzm.netty.operator.ServerHandlerAddOperator;
import com.xuzm.netty.operator.ServerHandlerExceptionOperator;
import com.xuzm.netty.operator.ServerHandlerReadOperator;
import com.xuzm.netty.operator.ServerHandlerRemoveOperator;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class ServerConfig {
    /**
     * 服务拦截消费的bean
     */
    @Bean
    public ServerHandlerConsumer serverHandlerConsumer(ServerHandlerAddOperator addOperator,
                                                       ServerHandlerReadOperator readOperator,
                                                       ServerHandlerExceptionOperator exceptionOperator,
                                                       ServerHandlerRemoveOperator removeOperator){
        return new ServerHandlerConsumer(addOperator::exec, readOperator::exec, exceptionOperator::exec, removeOperator::exec);
    }
}
